//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.view.components
{
	import flash.geom.Point;
	
	import mx.containers.TitleWindow;
	import mx.controls.TextInput;
	import mx.controls.ToolTip;
	import mx.managers.PopUpManager;
	import mx.managers.ToolTipManager;

	public class ErrorTipWindow extends TitleWindow
	{
		/////////////////////////////////////////////////////////////////////////////////
		//private variables
		
		private var errorTip:ToolTip;
		
		
		public function ErrorTipWindow()
		{
			super();
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//public methods
					
		public function closeWindow():void
		{
			this.hideErrorTip();
			PopUpManager.removePopUp(this);
		}
		
		public function showErrorTip(message:String, target:TextInput):void
		{
			this.hideErrorTip();
			var p:Point = target.localToGlobal(new Point(target.x, target.y));
			this.errorTip = ToolTipManager.createToolTip(message, p.x, p.y + target.height, "errorTipBelow") as ToolTip;
			this.focusManager.setFocus(target);
		}
		
		public function hideErrorTip():void
		{
			if(errorTip)
			{
				ToolTipManager.destroyToolTip(this.errorTip);
				this.errorTip = null;
			}
		}
	}
}